import { _decorator, Component, Node } from 'cc';
import { Util } from './Util';
import { PoolManager } from './PoolManager';
const { ccclass, property } = _decorator;

@ccclass('Weapon')
export class Weapon extends Component {

    attack:number = 10; // 攻击力
    speed:number = 5; // 移动速度
    moveDirection:number = 0; // 弧度
    isMoving:boolean = true; // 是否移动中

    resist:number = 0.1; // 阻力



    protected onEnable(): void {
        
    }

    protected onDisable(): void {
        
    }
    start() {

    }

    update(deltaTime: number) {
        if(this.isMoving) {
            Util.moveNode(this.node, this.moveDirection, this.speed);
            this.speed -= this.resist; // 减速
            if(this.speed <= 0) {
                this.isMoving = false;
                // this.node.destroy(); // 销毁武器
                PoolManager.instance.put(this.node); // 回收武器
            }
        }
    }
}


